<!DOCTYPE html>
<html>
<head>
<base href="../">
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="js/layer/layer.js"></script>
<script type="text/javascript" src="js/template.js"></script>
<script type="text/javascript" src="js/base.js"></script>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="css/bootstrap.min.css" >
<link rel="stylesheet" href="css/base.css" >
</head>
<body>
<script type="text/html" id="template1">
	<% for(var i=0;i<data.length;i++){ 
		var item=data[i];
	%>
		<tr>
         <td><%=item.code%></td>
         <td><%=item.date%></td>
        <td><%=item.desk_name%></td>
        <td><%=item.count%></td> 
         
				<td>
				<a href="javascript:;" onclick="up(this,<%=item.id%>)">上菜完成</a>
				</td>
		</tr>
    <%}%>
</script>
 <select  class="form-control search" name="search">
 </select>
 <button onclick="search();">查询</button>

<table class="table table-bordered">
 <thead>
<tr><td>单据号</td><td>日期</td><td>餐台</td><td>数量</td><td>功能</td></tr>
</thead>
<tbody>
</tbody>
</table>
<script type="text/javascript">
var id=getParam("id");
function up(target,id){

	openConfirm("确认上菜？",function(){
		var self=$(target);
		ajax_get("Order_Main/complet",{id:id,status:2},function(json){
			if(json.status<0){
				openAlert(json.data);
				return ;
			}
			location.reload();
		})
		
	})
	
}


function load(param){
	ajax_get("Order_Main/orderfooddetails",param,function(json){
		setSelect($("[name=search]"),"Order_Main/orderdetails_status",json.status);
		var myTemplate =  document.getElementById('template1').innerHTML; 
		  var myHtml = miniTpl(myTemplate, json.data);
		$("table tbody").empty();
		$("table tbody").append($(myHtml));
	})
}
function search(){
	var txt=$("[name=search]").val();
	load({search:txt,food_id:id})
}

$(function(){
	
	load({food_id:id,search:1})
	
		
	
	
})
</script>

</body>
</html>